package com.action.listBox;


import javax.swing.*;

public class ListComboBoxView {
    private JComboBox jComboBox;
    private ListComboBox listComboBox=null;
    private String item="选择属性";
    public ListComboBoxView(String[] nations){
        listComboBox=new ListComboBox();
//        System.out.println(nations[0]);
        listComboBox.setNations(nations);   //下拉表内容
        jComboBox=new JComboBox(listComboBox);
        jComboBox.setEditable(true);    //设为可编辑
    }
    //更改选项列表
    public void setNations(String[] nations){
        listComboBox.setNations(nations);
    }

    /**
     *
     * @return 得到JComboBox容器
     */
    public JComboBox getJComboBox(){
        return this.jComboBox;
    }

    /**
     *
     * @return 获得选择的内容
     */
    public String getItem(){
        return (String)listComboBox.getSelectedItem();
    }
    public void setItem(String item){
        listComboBox.setSelectedItem(item);
    }

}
